// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


const LL mask = (1LL<<40) - 1;

const int B = 5e5;
inline LL nxt(LL x) {
    return (x + (x >> 20) + 12345) & mask;
}

typedef pair<int, LL> piL;

inline piL nxt(piL p) {
    p.first++;
    p.second = nxt(p.second);
    return p;
}
piL s, t;

vector<LL> bl(LL a, int n) {
    vector<LL> res;
    res.reserve(B);
    int cnt = 0;
    for (int i=0; i<n; ++i) {
        if (i % B == 0) {
            res.push_back(a);
            res.push_back(cnt);
        }
        cnt += ((a & 1) == 0);
        a = nxt(a);
    }
    printf("%d\n", cnt);
    return res;
}

void dump(std::vector<LL> &a) {
    int n = sz(a);
    printf("{");
    for (int i=0; i<n; ++i) {
        printf("%lld%c", a[i], i<n-1? ',':'}');
    }
    putchar('\n');
}


int main(int argc, char const *argv[]) {
    // code
    s = piL(0, 1611516670);
    t = nxt(s);
    while (s.second != t.second) {
        s = nxt(s);
        t = nxt(nxt(t));
        // if (t.first - s.first % B == 0) {
        //     dbg(t.first - s.first);
        // }
    }
    int T = t.first - s.first;
    s = piL(0, 1611516670);
    t = s;
    for (int i=0; i<T; ++i)
        t = nxt(t);
    int offset = 0;
    while (s.second != t.second) {
        ++offset;
        s = nxt(s);
        t = nxt(t);
        // if (offset % B == 0) {
        //     dbg(offset);
        // }
    }
    dbg(offset, T);

    freopen("d.txt", "w", stdout);
    printf("%d %d\n", offset, T);
    vector<LL> voffset = bl(1611516670, offset),
    vT = bl(s.second, T);
    dump(voffset);
    dump(vT);

    return 0;
}
